﻿Imports QLTHUVIEN.DTO
Public Class TheLoaiSachDAO

    Public Function layDanhSach() As DataTable
        Dim strSql As String = "SELECT MaTheLoai, TenTheLoai FROM THELOAISACH WHERE isDelete ='False'"
        Dim dt As DataTable = DataProvider.ExecuteQuery(strSql)
        Return dt
    End Function

    Public Sub ThemTheLoai(ByVal TheLoai As TheLoaiSachDTO)
        Dim strSql As String = "INSERT INTO THELOAISACH(TenTheLoai) VALUES(N'" & TheLoai.TenTheLoaiSach & "')"
        DataProvider.ExecuteQuery(strSql)
    End Sub

    Public Sub SuaTheLoai(ByVal TheLoai As TheLoaiSachDTO)
        Dim strSql As String = "UPDATE THELOAISACH SET TenTheLoai =N'" & TheLoai.TenTheLoaiSach & "' WHERE MaTheLoai = " & TheLoai.MaTheLoaiSach
        DataProvider.ExecuteQuery(strSql)
    End Sub

    Public Sub XoaTheLoai(ByVal TheLoai As TheLoaiSachDTO)
        Dim strSql As String = "UPDATE THELOAISACH SET isDelete ='" & TheLoai.IsDelete.ToString() & "' WHERE MaTheLoai = " & TheLoai.MaTheLoaiSach
        DataProvider.ExecuteQuery(strSql)
    End Sub

End Class
